import numpy as np


class Bezier:
    def __init__(self) -> None:
        super().__init__()
        self.P: np.ndarray = np.zeros(0)

    def factorial(self, num: int) -> float:
        res = 1.0
        if num < 0:
            num = 0
        while num != 0:
            res *= num
            num -= 1
        return res

    def nchoosek(self, n: int, k: int) -> float:
        res = self.factorial(n) / (self.factorial(k) * self.factorial(n - k))
        return res

    def getOut(self, s: float) -> float:
        res = 0.0
        Np = self.P.size
        for i in range(Np):
            res += self.nchoosek(Np - 1, i) * np.power(1 - s, Np - 1 - i) * np.power(s, i) * self.P[i]
        return res

    def push_back(self, value: float):
        self.P = np.append(self.P, value)
